/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-12-21
 * Time: 10:54
 */
import java.util.*;
import java.io.*;

public class Main {
    static Map<Character, char[]> mp = new HashMap<>();
    static Set<Set<Character>> st = new HashSet<>();
    static {
        mp.put('a', new char[]{'f', 'b'});
        mp.put('b', new char[]{'a', 'g', 'c'});
        mp.put('c', new char[]{'d', 'g', 'b'});
        mp.put('d', new char[]{'c', 'e'});
        mp.put('e', new char[]{'d', 'g', 'f'});
        mp.put('f', new char[]{'a', 'g', 'e'});
        mp.put('g', new char[]{'f', 'e', 'c', 'b'});
    }

    static void dfs(Set<Character> curr, char c) {
        st.add(curr);
        if (curr.size() == 7) return;
        char[] get = mp.get(c);
        for (int i = 0; i < get.length; i++) {
            char ch = get[i];
            if (curr.contains(ch)) continue;
            Set<Character> newSet = new HashSet<>(curr);
            newSet.add(ch);
            dfs(newSet, ch);
        }
    }

    public static void main(String[] args) {
        for (char c = 'a'; c <= 'g'; ++c) {
            Set<Character> curr = new HashSet<>();
            curr.add(c);
            dfs(curr, c);
        }
        System.out.println(st.size());
    }
}
